home *** CD-ROM | disk | FTP | other *** search
/ Champak 119 / (Vol 119) Nov 09 2010.iso / Games / the_samurai.swf / scripts / frame_5 / DoAction.as < prev   
Text File  |  2010-11-09  |  5KB  |  213 lines

  1. function clearwudi()
  2. {
  3.    clearInterval(wuditimer);
  4.    man._alpha = 100;
  5.    wudi = false;
  6. }
  7. function showLiquid()
  8. {
  9.    i = 0;
  10.    while(i < liquids)
  11.    {
  12.       attachMovie("liquid","liquid" + i,i);
  13.       eval("liquid" + i)._xscale = eval("liquid" + i)._yscale = 80;
  14.       eval("liquid" + i)._x = 10 + i * 12;
  15.       eval("liquid" + i)._y = 188;
  16.       i++;
  17.    }
  18. }
  19. Key.addListener(this);
  20. wudi = false;
  21. onKeyDown = function()
  22. {
  23.    if(Key.isDown(65))
  24.    {
  25.       if(liquids > 0)
  26.       {
  27.          liquids--;
  28.          removeMovieClip(_root["liquid" + liquids]);
  29.          wudi = true;
  30.          man._alpha = 50;
  31.          var _loc2_ = setInterval(clearwudi,2000);
  32.          showLiquid();
  33.       }
  34.    }
  35.    if(Key.isDown(70))
  36.    {
  37.       if(liquids > 0)
  38.       {
  39.          liquids--;
  40.          removeMovieClip(_root["liquid" + liquids]);
  41.          score += 50;
  42.          attachMovie("50mc","fenshu",10001);
  43.          fenshu._x = 280;
  44.          fenshu._y = 80;
  45.          showLiquid();
  46.       }
  47.    }
  48.    if(Key.isDown(80))
  49.    {
  50.       if(Pause)
  51.       {
  52.          menu.gotoAndStop(1);
  53.          Pause = false;
  54.          man.mc.play();
  55.       }
  56.       else
  57.       {
  58.          menu.gotoAndPlay(2);
  59.          Pause = true;
  60.          man.mc.stop();
  61.       }
  62.    }
  63. };
  64. backSound = new Sound();
  65. backSound.attachSound("C42.WAV");
  66. backSound.start(0,999);
  67. hitSound = new Sound();
  68. hitSound.attachSound("sound3.mp3");
  69. upSound = new Sound();
  70. upSound.attachSound("sound5.mp3");
  71. spaceSound = new Sound();
  72. spaceSound.attachSound("sound4.mp3");
  73. stop();
  74. x = 3.8;
  75. jump = false;
  76. Pause = false;
  77. Lev = 1;
  78. level = Lev + "/25";
  79. life = 25;
  80. liquids = 0;
  81. score = 0;
  82. man._alpha = 100;
  83. lose = false;
  84. GameOver = false;
  85. _root.helpb._visible = false;
  86. man.onEnterFrame = function()
  87. {
  88.    if(!GameOver)
  89.    {
  90.       if(!Pause)
  91.       {
  92.          if(!lose)
  93.          {
  94.             this._x += x;
  95.             if(this.hitTest(liquid))
  96.             {
  97.                liquids++;
  98.                showLiquid();
  99.                liquid.swapDepths(_root.getNextHighestDepth());
  100.                removeMovieClip(liquid);
  101.             }
  102.             if(Key.isDown(38) || Key.isDown(32))
  103.             {
  104.                if(!jump)
  105.                {
  106.                   key = Key.getCode();
  107.                   if(key == 32)
  108.                   {
  109.                      spaceSound.start(0,1);
  110.                      y = 14;
  111.                      r = 12;
  112.                   }
  113.                   if(key == 38)
  114.                   {
  115.                      upSound.start(0,1);
  116.                      y = 10;
  117.                      r = 17;
  118.                   }
  119.                   maxFall = -15;
  120.                   jump = true;
  121.                }
  122.             }
  123.             if(jump)
  124.             {
  125.                this.gotoAndStop(2);
  126.                if(maxFall < y)
  127.                {
  128.                   y--;
  129.                }
  130.                this._y -= y;
  131.                this._rotation += r;
  132.                if(this._y >= 171)
  133.                {
  134.                   this._rotation = 0;
  135.                   this._y = 171;
  136.                   jump = false;
  137.                }
  138.             }
  139.             else
  140.             {
  141.                this.gotoAndStop(1);
  142.             }
  143.             if(this._x > 610)
  144.             {
  145.                this._x = -20;
  146.                score += 100;
  147.                if(Lev < 25)
  148.                {
  149.                   Lev++;
  150.                   level = Lev + "/25";
  151.                   _root.nextFrame();
  152.                }
  153.                else
  154.                {
  155.                   backSound.stop();
  156.                   i = 0;
  157.                   while(i < liquids)
  158.                   {
  159.                      removeMovieClip(_root["liquid" + i]);
  160.                      i++;
  161.                   }
  162.                   liquids = 0;
  163.                   gotoAndStop(30);
  164.                   _root.GameOver = true;
  165.                }
  166.             }
  167.          }
  168.          else
  169.          {
  170.             trace("X");
  171.             this._alpha -= 7;
  172.             this.mc.stop();
  173.             if(this._alpha <= 0)
  174.             {
  175.                life -= 1;
  176.                if(score > 0)
  177.                {
  178.                   score -= 1;
  179.                }
  180.                hit = false;
  181.                if(life != 0)
  182.                {
  183.                   this._x = -20;
  184.                   this._y = 171;
  185.                   jump = false;
  186.                   this.gotoAndStop(1);
  187.                   this._rotation = 0;
  188.                   this._alpha = 100;
  189.                   this.mc.play();
  190.                   lose = false;
  191.                }
  192.                else
  193.                {
  194.                   backSound.stop();
  195.                   i = 0;
  196.                   while(i < liquids)
  197.                   {
  198.                      removeMovieClip(_root["liquid" + i]);
  199.                      i++;
  200.                   }
  201.                   liquids = 0;
  202.                   this._x = -20;
  203.                   this._y = 171;
  204.                   this._alpha = 100;
  205.                   gotoAndStop(31);
  206.                   GameOver = true;
  207.                }
  208.             }
  209.          }
  210.       }
  211.    }
  212. };
  213.